package adminAction;

import dao.OrderDao;
import vo.OrderDetailVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/admin/adminAction/OrderDetailServlet")
public class OrderDetailServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String orderId = req.getParameter("orderId");
        Integer chose = Integer.parseInt(req.getParameter("chose"));
        OrderDao orderDao = new OrderDao();
        OrderDetailVo orderDetailVo = new OrderDetailVo();
        orderDetailVo = orderDao.findAddressAndOrder(orderId);
        orderDetailVo.setOrderWitnVos(orderDao.findItemList(orderId));
        req.setAttribute("details",orderDetailVo);
        if(chose!=2) {
            req.getRequestDispatcher("../page/order-detail.jsp").forward(req, resp);
        }else
        req.getRequestDispatcher("../page/order-process.jsp").forward(req, resp);
    }
}
